<template>
  <div id="app"><router-view /></div>
</template>

<script>
import { setToken, removeToken } from '@/utils/auth'
export default {
  name: 'App',
  created() {
    this.freePasswordLoginFun()
  },
  methods: {
    /* 免密登陆 */
    freePasswordLoginFun() {
      const href = window.location.href
      if (href.indexOf('?') !== -1) {
        const arr = href.substring(href.lastIndexOf('?') + 1, href.length).split('&')
        arr[arr.length - 1] = arr[arr.length - 1].substring(0, arr[arr.length - 1].lastIndexOf('#'))
        const obj = {}
        arr.forEach(item => {
          const arrKey = item.split('=')
          obj[arrKey[0]] = arrKey[1]
        })
        const token = obj.token
        if (token) {
          removeToken()
          setToken(token)
          this.$store.commit('SET_TOKEN', token)
          this.$store.state.user.token = token
          // 清空链接参数
          window.location.href = this.$route.path
        }
      }
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
#app {
	//min-width: 992px;
}
</style>
